/**
 * MiniGolf Scorecard
 * Copyright (C) 2010  MiriTheQuiet, http://minigolfscorecard.googlecode.com/
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package cz.mtq.mgsc.jsr75;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;

import cz.mtq.mgsc.MgscMidlet;
import cz.mtq.mgsc.Settings;
import cz.mtq.mgsc.command.AbstractCommand;
/**
 * 
 * @author MiriTheQuiet
 *
 */
public class FileBrowserCommand extends AbstractCommand {

	private final Displayable previous;
	
	private final MgscMidlet midlet;
	
	private FileBrowser browser;
	
	public FileBrowserCommand(int priority,int commandType, Displayable previous, MgscMidlet midlet) {
		super(new Command(Settings.getResource(Settings.TEXT_EXPORT_TO), commandType, priority), null);
		this.previous = previous;
		this.midlet = midlet;
	}

	protected void exec() throws Exception {
		//FileBrowser must be initiated and set as current
		if (browser == null){
			browser = new FileBrowser(midlet, previous);
		}
		else {
			browser.init();	
		}
		midlet.setCurrent(browser.getBrowser());
	}

}
